package com.shengsiyuan.netty.fourthexample;

import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.timeout.IdleStateHandler;

import java.util.concurrent.TimeUnit;

/**
 * @author 荀彧 2021/1/6
 */
public class MyServerInitializer extends ChannelInitializer<SocketChannel> {

    @Override
    protected void initChannel(SocketChannel ch) throws Exception {
        ChannelPipeline pipeline = ch.pipeline();
        // netty 的空闲状态检测的处理器。
        pipeline.addLast(new IdleStateHandler(5,
                7,10,
                TimeUnit.SECONDS));
        pipeline.addLast(new MyServerHandler());
    }
}

